<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Construct a new UTCDateTime</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="class.mongodb-bson-utcdatetime.html">« MongoDB\BSON\UTCDateTime</a></li>
      <li style="float: right;"><a href="mongodb-bson-utcdatetime.jsonserialize.html">MongoDB\BSON\UTCDateTime::jsonSerialize »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.mongodb-bson-utcdatetime.html">MongoDB\BSON\UTCDateTime</a></li>
    <li>Construct a new UTCDateTime</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="mongodb-bson-utcdatetime.construct" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">MongoDB\BSON\UTCDateTime::__construct</h1>
  <p class="verinfo">(mongodb &gt;=1.0.0)</p><p class="refpurpose"><span class="refname">MongoDB\BSON\UTCDateTime::__construct</span> &mdash; <span class="dc-title">Construct a new UTCDateTime</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-mongodb-bson-utcdatetime.construct-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">final</span> <span class="modifier">public</span> <span class="methodname"><strong>MongoDB\BSON\UTCDateTime::__construct</strong></span>(<span class="methodparam"><span class="type"><span class="type">int</span>|<span class="type">float</span>|<span class="type">string</span>|<span class="type"><a href="class.datetimeinterface.html" class="type DateTimeInterface">DateTimeInterface</a></span>|<span class="type">null</span></span> <code class="parameter">$milliseconds</code><span class="initializer"> = <strong><code>null</code></strong></span></span>)</div>

 </div>


 <div class="refsect1 parameters" id="refsect1-mongodb-bson-utcdatetime.construct-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt>
<code class="parameter">milliseconds</code> (<span class="type"><span class="type">int</span>|<span class="type">float</span>|<span class="type">string</span>|<span class="type"><a href="class.datetimeinterface.html" class="type DateTimeInterface">DateTimeInterface</a></span>|<span class="type">null</span></span>)</dt>

    <dd>

     <p class="para">
      Number of milliseconds since the Unix epoch (Jan 1, 1970). Negative values
      represent dates before 1970. This value may be provided as a 64-bit
      <span class="type">int</span>. For compatibility on 32-bit systems, this parameter
      may also be provided as a <span class="type">float</span> or <span class="type">string</span>.
     </p>
     <p class="para">
      If the argument is a <span class="classname"><a href="class.datetimeinterface.html" class="classname">DateTimeInterface</a></span>, the number
      of milliseconds since the Unix epoch will be derived from that value.
     </p>
     <p class="para">
      If this argument is <strong><code>null</code></strong>, the current time will be used by default.
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 errors" id="refsect1-mongodb-bson-utcdatetime.construct-errors">
  <h3 class="title">错误／异常</h3>
  <ul class="simplelist">
   <li class="member">Throws <span class="classname"><a href="class.mongodb-driver-exception-invalidargumentexception.html" class="classname">MongoDB\Driver\Exception\InvalidArgumentException</a></span> on argument parsing errors.</li>
  </ul>
 </div>


 <div class="refsect1 changelog" id="refsect1-mongodb-bson-utcdatetime.construct-changelog">
  <h3 class="title">更新日志</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>版本</th>
       <th>说明</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>PECL mongodb 1.2.0</td>
       <td>
        <p class="para">
         The <code class="parameter">milliseconds</code> argument is optional and
         defaults to <strong><code>null</code></strong> (i.e. current time). The argument also accepts a
         <span class="classname"><a href="class.datetimeinterface.html" class="classname">DateTimeInterface</a></span>, which may be used to derive
         the number of milliseconds since the Unix epoch. Previously, only
         <span class="type">int</span>, <span class="type">float</span>, and <span class="type">string</span> types
         were accepted.
        </p>
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-mongodb-bson-utcdatetime.construct-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-1394">
   <p><strong>示例 #1 <span class="function"><strong>MongoDB\BSON\UTCDateTime::__construct()</strong></span> example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />var_dump</span><span style="color: #007700">(new&nbsp;</span><span style="color: #0000BB">MongoDB</span><span style="color: #007700">\</span><span style="color: #0000BB">BSON</span><span style="color: #007700">\</span><span style="color: #0000BB">UTCDateTime</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(new&nbsp;</span><span style="color: #0000BB">MongoDB</span><span style="color: #007700">\</span><span style="color: #0000BB">BSON</span><span style="color: #007700">\</span><span style="color: #0000BB">UTCDateTime</span><span style="color: #007700">(new&nbsp;</span><span style="color: #0000BB">DateTime</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(new&nbsp;</span><span style="color: #0000BB">MongoDB</span><span style="color: #007700">\</span><span style="color: #0000BB">BSON</span><span style="color: #007700">\</span><span style="color: #0000BB">UTCDateTime</span><span style="color: #007700">(</span><span style="color: #0000BB">1416445411987</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>以上例程的输出类似于：</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
object(MongoDB\BSON\UTCDateTime)#1 (1) {
  [&quot;milliseconds&quot;]=&gt;
  string(13) &quot;1484852905560&quot;
}
object(MongoDB\BSON\UTCDateTime)#1 (1) {
  [&quot;milliseconds&quot;]=&gt;
  string(13) &quot;1484852905560&quot;
}
object(MongoDB\BSON\UTCDateTime)#1 (1) {
  [&quot;milliseconds&quot;]=&gt;
  string(13) &quot;1416445411987&quot;
}
</pre></div>
   </div>
  </div>
 </div>



 <div class="refsect1 seealso" id="refsect1-mongodb-bson-utcdatetime.construct-seealso">
  <h3 class="title">参见</h3>
  <ul class="simplelist">
   <li class="member"><a href="https://www.mongodb.com/docs/manual/reference/bson-types/#date" class="link external">&raquo;&nbsp;BSON Types: Date</a></li>
  </ul>
 </div>


</div></div></div></body></html>